#include "../include/head.h"

int recvn(int netfd,void* buf,long len,long* pProcessed)
{
    long processed = 0;
    char*p =(char*)buf;
    while(processed<len)
    {
        int ret = read(netfd,p+(processed),len-(processed));
        processed += ret;

        if(ret==0)
        {
            if(pProcessed!=NULL){*pProcessed = processed;}
            return -1;
        }
    }
    if(pProcessed!=NULL){*pProcessed = processed;}
    return 0;
}